import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './framework/login/login.component';
import { DefaultComponent } from './framework/default/default.component';
import { MainComponent } from './framework/main/main.component';

import { AuthGuard } from './utils/authguard.service';
import { RegisterComponent } from "./framework/register/register.component";
import { TokenComponent } from "./token/token.component";
import { MenuResolver } from "./utils/menuresolver.service";
import { FrameworkModule } from "./framework/framework.module";

const routes: Routes = [
  { path: '', redirectTo: '/login', pathMatch: 'full' },
  { path: 'login', component: LoginComponent },
  { path: 'register', component: RegisterComponent },
  { path: 'token', component: TokenComponent },
  {
    path: 'wel',
    resolve: {
      detail: MenuResolver
    },
    component: MainComponent,
    canActivate: [AuthGuard],
    canActivateChild: [AuthGuard],
    children: [
      { path: '', redirectTo: 'home', pathMatch: 'full' },
      { path: 'home', component: DefaultComponent },
      { path: 'demo', loadChildren: './view/demo/demo.module#DemoModule' }
    ]
  },
];

@NgModule({
  declarations: [],
  imports: [
    RouterModule.forRoot(routes),
    FrameworkModule
  ],
  exports: [RouterModule],
  providers: [AuthGuard]
})
export class AppRoutingModule {
}
